package com.hehao.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * header路由类型
 *
 * @Author Damon
 * @Date 2024/7/30 10:00
 */
@Slf4j
@Component
public class HeaderCustomer {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "headerQueue"),
            exchange = @Exchange(value = "testHeaderExchange", type = ExchangeTypes.HEADERS),
            key = "routeKey1"
    ))
    public void listener1(String msg) {
        log.info("listener1-->接收消息【header路由模式】：{}", msg);
    }


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "headerQueue"),
            exchange = @Exchange(value = "testHeaderExchange", type = ExchangeTypes.HEADERS),
            key = "routeKey2"
    ))
    public void listener2(String msg) {
        log.info("listener2-->接收消息【header路由模式】：{}", msg);
    }
}
